package com.zhangdi.dwcache.manager;

import net.sf.ehcache.CacheManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.PreDestroy;
import javax.annotation.Resource;

/**
 * Created by zhangdi on 2020/08/14 14:40:16.
 */
@Component
public class OnShutdown {
    private static final Logger logger = LoggerFactory.getLogger(OnShutdown.class);
    @Resource
    CacheManager cacheManager;

    @PreDestroy
    public void destroy() {
        if (null != cacheManager) {
            cacheManager.shutdown();
            logger.info("shutdown ehcache.");
        }
    }
}
